/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package calibracaolion;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 *
 * @author Santi
 */
@Entity
@Table(name = "instrumentos", catalog = "geins", schema = "")
@NamedQueries({
    @NamedQuery(name = "Instrumentos.findAll", query = "SELECT i FROM Instrumentos i"),
    @NamedQuery(name = "Instrumentos.findByCodInstrumento", query = "SELECT i FROM Instrumentos i WHERE i.codInstrumento = :codInstrumento"),
    @NamedQuery(name = "Instrumentos.findByTag", query = "SELECT i FROM Instrumentos i WHERE i.tag = :tag"),
    @NamedQuery(name = "Instrumentos.findByDescricao", query = "SELECT i FROM Instrumentos i WHERE i.descricao = :descricao"),
    @NamedQuery(name = "Instrumentos.findByNSerie", query = "SELECT i FROM Instrumentos i WHERE i.nSerie = :nSerie"),
    @NamedQuery(name = "Instrumentos.findByPeriodicidade", query = "SELECT i FROM Instrumentos i WHERE i.periodicidade = :periodicidade"),
    @NamedQuery(name = "Instrumentos.findByObs", query = "SELECT i FROM Instrumentos i WHERE i.obs = :obs"),
    @NamedQuery(name = "Instrumentos.findByCodLocal", query = "SELECT i FROM Instrumentos i WHERE i.codLocal = :codLocal"),
    @NamedQuery(name = "Instrumentos.findByCodFabricante", query = "SELECT i FROM Instrumentos i WHERE i.codFabricante = :codFabricante"),
    @NamedQuery(name = "Instrumentos.findByCodClasse", query = "SELECT i FROM Instrumentos i WHERE i.codClasse = :codClasse"),
    @NamedQuery(name = "Instrumentos.findByCodEmpresa", query = "SELECT i FROM Instrumentos i WHERE i.codEmpresa = :codEmpresa"),
    @NamedQuery(name = "Instrumentos.findByCodFamilia", query = "SELECT i FROM Instrumentos i WHERE i.codFamilia = :codFamilia")})
public class Instrumentos implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "cod_instrumento")
    private Integer codInstrumento;
    @Basic(optional = false)
    @Column(name = "tag")
    private String tag;
    @Basic(optional = false)
    @Column(name = "descricao")
    private String descricao;
    @Basic(optional = false)
    @Column(name = "n_serie")
    private String nSerie;
    @Basic(optional = false)
    @Column(name = "periodicidade")
    private String periodicidade;
    @Basic(optional = false)
    @Column(name = "obs")
    private String obs;
    @JoinColumn(name="cod_local",referencedColumnName="cod_local")
    @ManyToOne
    private Localizacoes codLocal;
    @JoinColumn(name="cod_fabricante",referencedColumnName="cod_fabricante")
    @ManyToOne
    private Fabricante codFabricante;
    @JoinColumn(name="cod_classe",referencedColumnName="cod_classe")
    @ManyToOne
    private Classes codClasse;
    @JoinColumn(name="cod_empresa",referencedColumnName="cod_empresa")
    @ManyToOne
    private Empresa codEmpresa;
    @JoinColumn(name="cod_familia",referencedColumnName="cod_familia")
    @ManyToOne
    private Familia codFamilia;
    @OneToMany(mappedBy = "codInstrumento")
    private List<Calibracao> calibracaoList;

    public Instrumentos() {
    }

    public Instrumentos(Integer codInstrumento) {
        this.codInstrumento = codInstrumento;
    }

    public Instrumentos(Integer codInstrumento, String tag, String descricao, String nSerie, String periodicidade, String obs, Localizacoes codLocal, Fabricante codFabricante, Classes codClasse, Empresa codEmpresa, Familia codFamilia) {
        this.codInstrumento = codInstrumento;
        this.tag = tag;
        this.descricao = descricao;
        this.nSerie = nSerie;
        this.periodicidade = periodicidade;
        this.obs = obs;
        this.codLocal = codLocal;
        this.codFabricante = codFabricante;
        this.codClasse = codClasse;
        this.codEmpresa = codEmpresa;
        this.codFamilia = codFamilia;
    }

    public Integer getCodInstrumento() {
        return codInstrumento;
    }

    public void setCodInstrumento(Integer codInstrumento) {
        Integer oldCodInstrumento = this.codInstrumento;
        this.codInstrumento = codInstrumento;
        changeSupport.firePropertyChange("codInstrumento", oldCodInstrumento, codInstrumento);
    }

    public String getTag() {
        return tag;
    }

    public void setTag(String tag) {
        String oldTag = this.tag;
        this.tag = tag;
        changeSupport.firePropertyChange("tag", oldTag, tag);
    }

    public String getDescricao() {
        return descricao;
    }

    public void setDescricao(String descricao) {
        String oldDescricao = this.descricao;
        this.descricao = descricao;
        changeSupport.firePropertyChange("descricao", oldDescricao, descricao);
    }

    public String getNSerie() {
        return nSerie;
    }

    public void setNSerie(String nSerie) {
        String oldNSerie = this.nSerie;
        this.nSerie = nSerie;
        changeSupport.firePropertyChange("NSerie", oldNSerie, nSerie);
    }

    public String getPeriodicidade() {
        return periodicidade;
    }

    public void setPeriodicidade(String periodicidade) {
        String oldPeriodicidade = this.periodicidade;
        this.periodicidade = periodicidade;
        changeSupport.firePropertyChange("periodicidade", oldPeriodicidade, periodicidade);
    }

    public String getObs() {
        return obs;
    }

    public void setObs(String obs) {
        String oldObs = this.obs;
        this.obs = obs;
        changeSupport.firePropertyChange("obs", oldObs, obs);
    }

    public Localizacoes getCodLocal() {
        return codLocal;
    }

    public void setCodLocal(Localizacoes codLocal) {
        Localizacoes oldCodLocal = this.codLocal;
        this.codLocal = codLocal;
        changeSupport.firePropertyChange("codLocal", oldCodLocal, codLocal);
    }

    public Fabricante getCodFabricante() {
        return codFabricante;
    }

    public void setCodFabricante(Fabricante codFabricante) {
        Fabricante oldCodFabricante = this.codFabricante;
        this.codFabricante = codFabricante;
        changeSupport.firePropertyChange("codFabricante", oldCodFabricante, codFabricante);
    }

    public Classes getCodClasse() {
        return codClasse;
    }

    public void setCodClasse(Classes codClasse) {
        Classes oldCodClasse = this.codClasse;
        this.codClasse = codClasse;
        changeSupport.firePropertyChange("codClasse", oldCodClasse, codClasse);
    }

    public Empresa getCodEmpresa() {
        return codEmpresa;
    }

    public void setCodEmpresa(Empresa codEmpresa) {
        Empresa oldCodEmpresa = this.codEmpresa;
        this.codEmpresa = codEmpresa;
        changeSupport.firePropertyChange("codEmpresa", oldCodEmpresa, codEmpresa);
    }

    public Familia getCodFamilia() {
        return codFamilia;
    }

    public void setCodFamilia(Familia codFamilia) {
        Familia oldCodFamilia = this.codFamilia;
        this.codFamilia = codFamilia;
        changeSupport.firePropertyChange("codFamilia", oldCodFamilia, codFamilia);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (codInstrumento != null ? codInstrumento.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Instrumentos)) {
            return false;
        }
        Instrumentos other = (Instrumentos) object;
        if ((this.codInstrumento == null && other.codInstrumento != null) || (this.codInstrumento != null && !this.codInstrumento.equals(other.codInstrumento))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "calibracaolion.Instrumentos[codInstrumento=" + codInstrumento + "]";
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }

}
